package com.gjs.cd.controller;

import com.gjs.cd.pojo.dto.AgreementDTO;
import com.gjs.cd.service.IAgreementService;
import com.gjs.common.enums.entity.StatusEnum;
import com.gjs.common.manager.response.RspBody;
import com.gjs.common.microservice.api.IResourceMicroService;
import com.gjs.common.pojo.dto.resource.TypeDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhongwenguang
 * @date 2022-3-17 10:14
 */
@RestController
@Slf4j
@Api(tags = "公共数据")
@RequestMapping("/common")
@RequiredArgsConstructor
public class CommonController {

    @DubboReference
    private IResourceMicroService iResourceMicroService;

    @Autowired
    private IAgreementService iAgreementService;

    //获取学科及id
    @GetMapping("/get_subject")
    @ApiOperation("获取学科及id")
    public RspBody<List<TypeDTO>> getSubjectInfo(){
        return RspBody.success(iResourceMicroService.listSubjects());
    }

    //获取版本及id
    @GetMapping("/get_editions")
    @ApiOperation("获取版本及id")
    public RspBody<List<TypeDTO>> getEditions(){
        return RspBody.success(iResourceMicroService.listEditions());
    }

    //获取学段及id
    @GetMapping("/get_periods")
    @ApiOperation("获取学段及id")
    public RspBody<List<TypeDTO>> getPeriods(){
        return RspBody.success(iResourceMicroService.listPeriods());
    }

    //获取学段及id
    @GetMapping("/get_stages")
    @ApiOperation("获取年级及id")
    public RspBody<List<TypeDTO>> getStages(){
        return RspBody.success(iResourceMicroService.listStages());
    }

    //获取状态
//    @GetMapping("/get_status")
//    @ApiOperation("获取状态枚举")
//    public RspBody<List<StatusEnum>> getStatus(){
//        return RspBody
//    }

    //获取协议
    @GetMapping("/get_agreement_details")
    @ApiOperation("获取光盘协议")
    public RspBody<AgreementDTO> getAgreementDetails(Long id){
        return RspBody.success(iAgreementService.getAgreementDetails(id));
    }

}
